﻿using System;
using _3D_Concept;

namespace GameLogic
{
    class LogicController
    {
        /// <summary>
        /// Stores the last block ID.
        /// </summary>
        private int IDCounter;
        /// <summary>
        /// Represents the 2D GameField in a 2D Property.
        /// </summary>
        public LogicBlock[,] GameField { get; set; }

        /// <summary>
        /// Creates an instance of LogicControl with a default field of 10x20.
        /// </summary>
        public LogicController()
        {
            GameField = new LogicBlock[10, 20];
        }

        /// <summary>
        /// Creates an instance of LogicControl with given width and height.
        /// </summary>
        /// <param name="width">The width of the GameField.</param>
        /// <param name="height">The Height of the GameField.</param>
        public LogicController(int width, int height)
        {
            GameField = new LogicBlock[width, height];
        }

        /// <summary>
        /// Add a new dynamic block into the system.
        /// </summary>
        public void CreateMovingBlock()
        {
            Random rand = new Random();
            int randomShape = rand.Next(0, 6);

            // Add a new Block into the GameField
            GameField[GameField.GetLength(0) / 2, GameField.GetLength(1) / 2] 
                = new LogicBlock(IDCounter, (Shape)randomShape);

            // Increment the ID Counter
            ++IDCounter;
        }
    }
}
